import type { AppRouteRecordRaw } from '@/types/router'

// 使用 Vite 的 import.meta.glob 实现真正的懒加载
const modules = import.meta.glob('../../views/**/*.vue')

/**
 * 商品库路由
 */
export const productRoutes: AppRouteRecordRaw[] = [
	{
		path: '/product',
		meta: {
			title: '路由.商品库',
			permission: '商品库',
			isMenu: true
		},
		showSubMenu: true,
		children: [
			{
				path: '/product/categories',
				component: modules['../../views/product/category/CateManager.vue'],
				meta: {
					title: '路由.分类管理',
					permission: '商品库-分类管理',
					isMenu: true
				}
			},
			{
				path: '/product/suppliers',
				component: modules['../../views/product/supplier/SupplierList.vue'],
				meta: {
					title: '路由.供应商管理',
					permission: '商品库-供应商管理',
					isMenu: true
				}
			},
			{
				path: '/product/goods',
				meta: {
					title: '路由.商品管理',
					permission: '商品库-商品管理',
					isMenu: true
				},
				redirect: '/product/goods/list',
				children: [
					{
						path: '/product/goods/list',
						component: modules['../../views/product/goods/GoodsList.vue'],
						meta: {
							title: '路由.商品列表',
							permission: '商品库-商品管理-商品列表'
						}
					},
					{
						path: '/product/goods/add',
						component: modules['../../views/product/goods/GoodsForm.vue'],
						meta: {
							title: '路由.添加商品',
							permission: '商品库-商品管理-添加商品',
							hasFooterToolbar: true
						}
					},
					{
						path: '/product/goods/edit',
						component: modules['../../views/product/goods/GoodsForm.vue'],
						meta: {
							title: '路由.修改商品',
							permission: '商品库-商品管理-修改商品',
							hasFooterToolbar: true
						}
					},
					{
						path: '/product/goods/copy',
						component: modules['../../views/product/goods/GoodsForm.vue'],
						meta: {
							title: '路由.复制商品',
							permission: '商品库-商品管理-复制商品',
							hasFooterToolbar: true
						}
					},
					{
						path: '/product/goods/info',
						component: modules['../../views/product/goods/GoodsInfo.vue'],
						meta: {
							title: '路由.商品详细',
							permission: '商品库-商品管理-商品详细',
							hasFooterToolbar: true
						}
					},
					{
						path: '/product/goods/materialEdit',
						component: modules['../../views/product/goods/MaterialEditor.vue'],
						meta: {
							title: '路由.素材编辑',
							permission: '商品库-商品管理-素材编辑',
							hasFooterToolbar: true
						}
					}
				]
			}
		]
	}
]
